package pikes.peak;

import java.util.Map;

import org.springframework.web.servlet.support.RequestContext;

import pikes.html.xhtml.table.TR;

public class Row implements RequestProperty<TR> {

	private CellCollection cellCollection = new CellCollection(RowDecorator.NULL_DECORATOR);

	public Row() {

	}

	public Row(final RowDecorator rowDecorator) {
		cellCollection = new CellCollection(rowDecorator);
	}

	public final TR getValue(Map model, RequestContext requestContext) throws Exception {
		return cellCollection.getValue(model, requestContext);
	}

	public final void addCell(Component component) {
		addCell(component, CellDecorator.NULL_DECORATOR);
	}

	public final void addHeaderCell(Component component) {
		if (component != null) {
			cellCollection.add(new Cell(true, component, CellDecorator.NULL_DECORATOR));
		}
	}

	public final void addCell(Component component, CellDecorator cellDecorator) {
		if (component != null) {
			cellCollection.add(new Cell(component, cellDecorator));
		}
	}

	public final void addHeaderCell(Component component, CellDecorator cellDecorator) {
		if (component != null) {
			cellCollection.add(new Cell(true, component, cellDecorator));
		}
	}

	public final void addCell(Component[] componentArray) {
		addCell(componentArray, CellDecorator.NULL_DECORATOR);

	}

	public final void addHeaderCell(Component[] componentArray) {
		if (componentArray != null) {
			cellCollection.add(new Cell(true, componentArray, CellDecorator.NULL_DECORATOR));
		}
	}

	public final void addCell(Component[] componentArray, CellDecorator cellDecorator) {
		if (componentArray != null) {
			cellCollection.add(new Cell(componentArray, cellDecorator));
		}
	}

	public final void addHeaderCell(Component[] componentArray, CellDecorator cellDecorator) {
		if (componentArray != null) {
			cellCollection.add(new Cell(true, componentArray, cellDecorator));
		}
	}

}
